/******************************************************************************
 * (C) Copyright 2013 Atech-Automotive
 * FILE NAME:    uds_diag_ioctrl_fun.c
 * DESCRIPTION:
 *
 * DATE BEGUN:   2015/06/17
 * BY:           hui.pang
 * PRODUCT NAME:
 * APPLICATION:
 * TARGET H/W:
 * DOC REF:
 *****************************************************************************
 */

/*****************************************************************************
** #include
*****************************************************************************/
#include "system.h"
#include "uds_diag_appl.h"
#include "uds_diag_ioctrl_fun.h"

#pragma CODE_SEG  OTHER_ROM


#ifdef MODE_2F_SUPPORTED

/*****************************************************************************
** function prototypes
*****************************************************************************/


/****************************************************************************/
/**
 * Function Name: UdsIOCtrlFun_ExitIoCtrlState
 * Description: exit the io ctrl state, when the uds timeout or into default session mode
 *
 * Param:   none
 * Return:  none
 * Author:  2016/08/16, hui.liu create this function
 ****************************************************************************/
void UdsIOCtrlFun_ExitIoCtrlState( void )
{
    UINT8 temp;
    /* io ctrl retrun to ecu when diag timeout */
	
	#if 0
    UdsIOCtrlFun_Digital_Input1(IO_CTRL_CMD_RETURN_TO_ECU, &temp);
    UdsIOCtrlFun_OutPut2(IO_CTRL_CMD_RETURN_TO_ECU, &temp);
	#endif
}


/****************************************************************************/
/**
 * Function Name: UdsIOCtrlFun_OutPut1
 * Description: response NRC22 if return value is FALSE
 *
 * Param:   none
 * Return:  none
 * Author:  2016/07/25,  create this function
 ****************************************************************************/
UINT8 UdsIOCtrlFun_Digital_Input1(Uds_IOCtrl_Cmd_E cmd, UINT8 *p_u8_data)
{
    UINT8 resp = FALSE;
    (void)cmd;
    (void)p_u8_data;

    if(cmd == IO_CTRL_CMD_RETURN_TO_ECU)
    {
		#if 0
        HWA_SetInputReEcu(SI_HAZARD_IN,         TRUE);
		#endif
        
        resp = TRUE;
    }
    else if(cmd == IO_CTRL_CMD_RESET_TO_DEFAULT)
    {
        resp = TRUE;
    }
    else if(cmd == IO_CTRL_CMD_FREEZE_CURRENT_STATE)
    {
        resp = TRUE;
    }
    else if(cmd == IO_CTRL_CMD_SHORT_TERM_ADJUSTMENT)
    {
		#if 0
        HWA_SetInputByUds(SI_HAZARD_IN,        TEST(p_u8_data[0] & BIT7), TEST(p_u8_data[4] & BIT7), IO_CTRL_TIME_LONG);
		#endif
        
        resp = TRUE;
    }
    return resp;
}

/****************************************************************************/
/**
 * Function Name: UdsIOCtrlFun_OutPut1
 * Description: response NRC22 if return value is FALSE
 *
 * Param:   none
 * Return:  none
 * Author:  2016/07/25,  create this function
 ****************************************************************************/
UINT8 UdsIOCtrlFun_OutPut1(Uds_IOCtrl_Cmd_E cmd, UINT8 *p_u8_data)
{
    UINT8 resp = FALSE;
    (void)cmd;
    (void)p_u8_data;

	#if 0
    if(app_can0GetEnginState() == TRUE && TEST(p_u8_data[6] & BIT4))
    {
        return FALSE;
    }
	#endif

    if(cmd == IO_CTRL_CMD_RETURN_TO_ECU)
    {
		#if 0
        //////////////////////////BYTE 0////////////////////////////
        HWA_SetOutputReEcu(SO_HIGH_BEAM_L_OUT,      TRUE);
		#endif
        resp = TRUE;
    }
    else if(cmd == IO_CTRL_CMD_RESET_TO_DEFAULT)
    {
        resp = TRUE;
    }
    else if(cmd == IO_CTRL_CMD_FREEZE_CURRENT_STATE)
    {
        resp = TRUE;
    }
    else if(cmd == IO_CTRL_CMD_SHORT_TERM_ADJUSTMENT)
    {
		#if 0
        //////////////////////////BYTE 0////////////////////////////
        HWA_SetOutputByUds(SO_HIGH_BEAM_L_OUT,     TEST(p_u8_data[0] & BIT7),  TEST(p_u8_data[4] & BIT7),  IO_CTRL_TIME_LONG);
        #endif
        resp = TRUE;
    }
    return resp;
}


#endif /* MODE_2F_SUPPORTED */

#pragma CODE_SEG  DEFAULT


/*****************************************************************************
** End File
*****************************************************************************/

